#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <cmath>

#define DIM 13
#define BIG_NUMBER 9999999999999

using namespace std;

class Series{
  int lengthSeries;
  int classification;
  double **series;
  double *mag;
  int *upperIndex, *lowerIndex;
public:
  static Series * createNewSeries();
  static void  freeMem(Series *ptr);
  void addLine(string s, int line);
  int getMag(int i);
  int setMag(int m, int i);    
  int getLength();
  void setLength(int num);
  int *getUpper();
  int *getLower();
  int setUpper(int * upper);
  int setLower(int * lower);
  double ** getSeries();
  int getClass();
  void setClass(int c);
};

double calDist(double *pt1, double *pt2);
double dtw(double **trainBlock,int trainSize, double **testBlock, int testSize);
double dtw(double **trainBlock,int trainSize, double **testBlock, int testSize, int window);
int kNN(Series **trainingset, Series entry, int k, int window);
Series **init(int datasetSize, int chunkSize, string filename, double sampleRate, int *finalSize);
void getUpperLowerIndex(Series *train, int window);
double calcLowerBound(Series *train, Series *test, int window);
double getAccuracy(Series **train, int trainingSize, Series **test, int testSize,int option, int k, int window);
void destroy(Series **setData, int setSize);
double getAccuracy(Series **train, int trainingSize, Series **test, int testSize, int k, int window);
void parseCommand(int argc, char *argv[], int *option, int *window, int *k, double *sampleRate);
